<template>
	<view class="body">
		<view class="imags"><image src="../../static/image/vib_img.png" class="img"></image></view>

		<view>
			<checkbox-group @change="changeRadio">
				<view class="inputadd" v-for="item in carList" :key="item.id">
					<view class="addviss">
						<text class="iconfont icon-yongchegongche"></text>
						<text class="jing">{{ item.carno }}</text>
					</view>
					<view>
						<label class="radio"><checkbox :value="item.id" /></label>
					</view>
				</view>
			</checkbox-group>
			<strong></strong>
		</view>
		<view><button type="default" class="delcar" display="none" @click="delcar">删除</button></view>
	</view>
</template>

<script>
import { carList, deltcar } from './../../utils/car/car.js';
export default {
	data() {
		return {
			checkeds: false,
			checkedst: false,
			disnone: true,
			carList: [],
			ids: []
		};
	},
	onLoad() {
		this.getcarList();
	},
	methods: {
		async getcarList() {
			uni.showLoading({
				title:'加载中'
			})
			const res = await carList();
			console.log(res);
			if (res.errCode == 10000) {
				uni.hideLoading()
				this.carList = res.data.list;
				this.carList.forEach(item => {
					item.id = item.id.toString();
				});
			}
		},
		changeRadio(e) {
			console.log(e, this.carList);
			let valus = e.detail.value;
			var carList = this.carList;
			this.ids = valus;
			console.log(this.ids);
		},
		onNavigationBarButtonTap(e) {
			if (e.index == 0) {
				uni.navigateTo({
					url: './index'
				});
			}
		},
		async delcar() {
			let ids = this.ids;
			const res = await deltcar({ ids });
			var thst = this
			uni.showModal({
				title: '提示',
				content: '是否要删除选中车辆',
				success: function(res) {
					if (res.confirm) {
						thst.getcarList();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		}
	}
};
</script>

<style lang="less">
@import './../../static/style/addcar.less';
</style>
